package com.aiolos.weather.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * 配置RestTemplate的具体实现
 *
 * 我们已经加入了Apache Client的依赖
 * RestTemplate启动时默认从classpath中寻找这个依赖作为具体实现
 */
@Configuration
public class RestConfiguration {

    @Autowired
    private RestTemplateBuilder builder;

    @Bean
    public RestTemplate restTemplate(){
        //通过RestTemplateBuilder生成RestTemplate
        return builder.build();
    }
}
